package com.gxkj.movie.controllers;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gxkj.movie.controllers.seo.IndexSeo;
import com.gxkj.movie.helpers.*;
import com.gxkj.movie.threads.BaiduSubmitUrlThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * @author sqyc
 */
@Controller
@Slf4j
public class CustomperPlayController extends BaseController {

    @Autowired
    private MovSiteHelpper movSiteHelpper;



    @Autowired
    private BaiduSpiderHelper baiduSpiderHelper;



    @GetMapping("customperplay")
    public String index(HttpServletRequest req, Model model,@RequestParam(value = "forceclear" ,required=false,defaultValue ="false") Boolean forceclear){



        String basePath = req.getScheme()+"://"+req.getServerName()+"/english";
        System.out.println("basePath="+basePath);
        String[] param = {
                //需要推送的网址
                basePath
        };

        new Thread(new BaiduSubmitUrlThread(baiduSpiderHelper,param)).start();
        if(forceclear){
            cache.clear();
        }
        renderHeader(  req,   model);



        //推荐视频
        renderRecommendVod( req,   model);
        //新闻提示
        renderNews(req,   model,null);

        return getTempletate(req)+"/customperplay";
    }

    @Override
    public void renderHeader(HttpServletRequest req, Model model){
        super.renderHeader(req,model);
        model.addAttribute("menu", MenuEnum.CUSTOMPERPLAY.getKey());
        model.addAttribute("TITLE", IndexSeo.CUSTOMPERPLAY);
        model.addAttribute("KEYWORDS",IndexSeo.CUSTOMPERPLAY);
        model.addAttribute("DESCRIPTION",IndexSeo.CUSTOMPERPLAY);
        model.addAttribute("SITE_NAME", IndexSeo.CUSTOMPERPLAY);
    }



}
